home *** CD-ROM | disk | FTP | other *** search
/ The Very Best of Atari Inside / The Very Best of Atari Inside 1.iso / mint / mntinc25 / fcntl.h < prev    next >
C/C++ Source or Header  |  1992-10-18  |  3KB  |  129 lines

  1. /*
  2.  *    FCNTL.H
  3.  */
  4.  
  5. #ifndef    _FCNTL_H
  6. #define    _FCNTL_H
  7.  
  8. #ifndef _COMPILER_H
  9. #include <compiler.h>
  10. #endif
  11.  
  12. #ifdef __cplusplus
  13. extern "C" {
  14. #endif
  15.  
  16. #define    O_RDONLY    0x00        /* read only */
  17. #define    O_WRONLY    0x01        /* write only */
  18. #define    O_RDWR        0x02        /* read/write */
  19. #define O_ACCMODE    0x03        /* used to mask off file access mode */
  20.  
  21. /* file sharing modes (not POSIX) */
  22. #define O_COMPAT    0x00        /* old TOS compatibility mode */
  23. #define O_DENYRW    0x10        /* deny both reads and writes */
  24. #define O_DENYW        0x20
  25. #define O_DENYR        0x30
  26. #define O_DENYNONE    0x40        /* don't deny anything */
  27. #define O_SHMODE    0x70        /* mask for file sharing mode */
  28.  
  29. #define    O_NDELAY    0x100        /* Non-blocking I/O */
  30. #ifdef __MINT__
  31. # define O_SYNC        0x00        /* sync after writes (not implemented) */
  32. #endif
  33.  
  34. /* the following flags are not passed to the OS */
  35. #define    O_CREAT        0x200        /* create new file if needed */
  36. #define    O_TRUNC        0x400        /* make file 0 length */
  37. #define    O_EXCL        0x800        /* error if file exists */
  38. #define    O_APPEND    0x1000        /* position at EOF */
  39. #define _REALO_APPEND    0x08        /* this is what MiNT uses */
  40. #ifndef __MINT__
  41. # define O_PIPE        0x2000        /* serial pipe     */
  42. #endif
  43.  
  44. /*
  45.  * defines for the access() function
  46.  */
  47. #define    F_OK            0
  48. #define    X_OK            1
  49. #define    W_OK            2
  50. #define    R_OK            4
  51.  
  52. /*
  53.  * defines for fcntl()
  54.  */
  55. #define    F_DUPFD        0    /* Duplicate fildes */
  56. #define    F_GETFD        1    /* Get fildes flags */
  57. #define    F_SETFD        2    /* Set fildes flags */
  58. #define    F_GETFL        3    /* Get file flags */
  59. #define    F_SETFL        4    /* Set file flags */
  60.  
  61. #ifdef __MINT__
  62. #define F_GETLK        5    /* Get file lock */
  63. #define F_SETLK        6    /* Set file lock */
  64.  
  65. struct flock {
  66.     short l_type;
  67. #define F_RDLCK        O_RDONLY
  68. #define F_WRLCK        O_WRONLY
  69. #define F_UNLCK        3
  70.     short l_whence;
  71.     long l_start;
  72.     long l_len;
  73.     short l_pid;
  74. };
  75. #endif /* __MINT__ */
  76.  
  77.  
  78. #ifdef __MINT__
  79.  
  80. #define __NHANDLES 40
  81.  
  82. struct __open_file {
  83.     short    status;        /* whether or not it's a tty */
  84.     short    flags;        /* if a tty, its flags */
  85. };
  86.  
  87. #else
  88.  
  89. #define __NHANDLES    80
  90. struct __open_file {
  91.     unsigned short append:1;    /* 1 if O_APPEND set for this file */
  92.     unsigned short nodelay:1;    /* 1 if O_NDELAY set for this file */
  93.     unsigned short pipe:1;      /* 1 if O_PIPE set for this file */
  94.     unsigned short eclose:1;    /* 1 if close on exec is set for this file */
  95.     unsigned short status:2;    /* status FH_UNKNOWN | ISATTY | ISAFILE */
  96.     char       *filename;    /* filename of open file */
  97. };
  98.  
  99. #endif /* __MINT__ */
  100.  
  101. extern struct __open_file __open_stat[__NHANDLES];
  102.   /* NOTE: this array is indexed by (__OPEN_INDEX(fd)) */
  103.  
  104. /* smallest valid gemdos handle */
  105. /* note handle is only word (16 bit) negative, not long negative,
  106.    and since Fopen etc are declared as returning long in osbind.h
  107.    the sign-extension will not happen -- thanks ers
  108. */
  109. #ifdef __MSHORT__
  110. #define __SMALLEST_VALID_HANDLE (-3)
  111. #else
  112. #define __SMALLEST_VALID_HANDLE (0)
  113. #endif
  114.  
  115. #define __OPEN_INDEX(x)    (((short)(x)) + 3)
  116.  
  117. #define FH_UNKNOWN    0
  118. #define FH_ISATTY    1
  119. #define FH_ISAFILE    2
  120.  
  121.  
  122. __EXTERN int fcntl __PROTO((int f, int cmd, ...));
  123.  
  124. #ifdef __cplusplus
  125. }
  126. #endif
  127.  
  128. #endif /* _FCNTL_H */
  129.